package xyz.liut.ee.api

import jakarta.servlet.annotation.WebServlet
import jakarta.servlet.http.HttpServletRequest
import jakarta.servlet.http.HttpServletResponse
import xyz.liut.ee.req.getSimpleReqInfo
import xyz.liut.ee.resp.ResponseEntity
import xyz.liut.ee.resp.sendBy
import xyz.liut.ee.web.BaseServlet

/**
 * 模拟 HTTP 超时操作
 */
@WebServlet("/timeout")
class TimeOut : BaseServlet() {

    override fun service(req: HttpServletRequest, resp: HttpServletResponse) {
        Thread.sleep(30000)
        super.service(req, resp)

        val reqInfo = req.getSimpleReqInfo()

        val respBean = ResponseEntity(
            msg = "半分钟到了",
            code = 200,
            data = reqInfo
        )
        respBean.sendBy(resp)
    }


    override fun doHead(req: HttpServletRequest?, resp: HttpServletResponse?) {
    }

    override fun doGet(req: HttpServletRequest?, resp: HttpServletResponse?) {
    }

    override fun doPost(req: HttpServletRequest?, resp: HttpServletResponse?) {
    }


}
